package com.kecheng.xinmei.controller.admin;

import com.kecheng.xinmei.entity.*;
import com.kecheng.xinmei.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * @author gaokecheng
 * @version 1.0
 * @date 2020/11/20 4:21 下午
 */
@RestController
@RequestMapping(value = "/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;

    @PostMapping(value = "/add_doctor")//添加教授
    public Boolean addDoctor( @RequestBody Doctor doctor){
        return adminService.addDoctor(doctor);
    }
    @PostMapping(value = "/update_doctor")//更新教授
    public Boolean updateDoctor( @RequestBody Doctor doctor){
        return adminService.updateDoctor(doctor);
    }
    @PostMapping(value = "/add_lunbo")//添加轮播图
    public Boolean addLunbo( @RequestBody Lunbo lunbo){
        return adminService.addLunbo(lunbo);
    }
    @GetMapping(value = "/delete_lunbo")//删除轮播图
    public Boolean deleteLunbo(@RequestParam("id") Integer id){
        return adminService.deleteLunbo(id);
    }
    @PostMapping(value = "/add_topic")//添加研究课题
    public Boolean addTopic( @RequestBody Topic topic){
        return adminService.addTopic(topic);
    }
    @PostMapping(value = "/update_topic")//更新研究课题
    public Boolean updateTopic( @RequestBody Topic topic){
        return adminService.updateTopic(topic);
    }
    @PostMapping(value = "/add_life")//添加生活随记
    public Boolean addLife( @RequestBody Life life){
        return adminService.addLife(life);
    }
    @PostMapping(value = "/update_life")//更新生活随记
    public Boolean updateLife( @RequestBody Life life){
        return adminService.updateLife(life);
    }
    @PostMapping(value = "/add_person")//添加人（学生，老师，已毕业学生）
    public Boolean addPerson( @RequestBody Person person){
        return adminService.addPerson(person);
    }
    @GetMapping(value = "/delete_person")//删除人
    public Boolean deletePerson(@RequestParam("id") Integer id){
        return adminService.deletePerson(id);
    }
    @PostMapping(value = "/update_introduction")//添加介绍
    public Boolean updateIntroduction( @RequestBody Introduction introduction){
        return adminService.updateIntroduction(introduction);
    }
    @GetMapping(value = "/delete_introduction")//删除介绍
    public Boolean deleteIntroduction(@RequestParam("id") Integer id){
        return adminService.deleteIntroduction(id);
    }
    @PostMapping(value = "/add_news")//添加新闻
    public Boolean addNews( @RequestBody News news){
        news.setTtime(new Date());
        return adminService.addNews(news);
    }
    @GetMapping(value = "/delete_news")//删除新闻
    public Boolean deleteNews( @RequestParam("id") Integer id){
        return adminService.deleteNews(id);
    }
    @PostMapping(value = "/add_result")//添加研究成果
    public Boolean addResult( @RequestBody Result result){
        result.setRtime(new Date());
        return adminService.addResult(result);
    }
    @GetMapping(value = "/delete_result")//删除研究成果
    public Boolean deleteResult( @RequestParam("id") Integer id){
        return adminService.deleteResult(id);
    }

}
